package ink.xiaobaibai.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import ink.xiaobaibai.common.PageInfo;
import ink.xiaobaibai.common.SelectBuyBo;
import ink.xiaobaibai.dao.BuyOzoneDeviceDao;
import ink.xiaobaibai.entity.BuyOzoneDevice;
import ink.xiaobaibai.service.IBuyOzoneDeviceService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author xiaobaibai
 * @since 2021-06-12
 */
@Service
public class BuyOzoneDeviceServiceImpl extends ServiceImpl<BuyOzoneDeviceDao, BuyOzoneDevice> implements IBuyOzoneDeviceService {

    @Override
    public PageInfo<BuyOzoneDevice> getList(SelectBuyBo selectBuyBo) {
        return new PageInfo<>(this.baseMapper.getList(selectBuyBo), this.baseMapper.getCount(selectBuyBo), selectBuyBo.getPageSize());
    }

    @Override
    public boolean okCode(String deviceCode) {
        QueryWrapper<BuyOzoneDevice> q1 = new QueryWrapper<>();
        q1.eq("device_code", deviceCode);
        return this.count(q1) == 0;
    }

    @Override
    public String getOxygenCodeByDeviceCode(String deviceCode) {
        return this.baseMapper.getOxygenCodeByDeviceCode(deviceCode);
    }

}
